package hc.trip.airticket.result;

import hc.trip.airticket.bean.FlightInfo;
import hc.trip.airticket.bean.PriceInfo;
import hc.trip.airticket.bean.ResultInfo;

import java.util.Iterator;
import java.util.List;


/**
 * 打印结果
 * @author xhyao
 *
 */
public class PrintFlightInfo {

	
	public void sysoutFlights(ResultInfo resultInfo){
		FlightInfo flightInfo = null;
		PriceInfo  priceInfo = null;
		if (resultInfo==null) {
			System.out.println("***********没有航班信息***************");return;
		}
		List resultList =  resultInfo.getResultList();
		if(resultList==null||resultList.isEmpty()){
			System.out.println("***********没有航班信息***************");
			return;
		}
		
		Iterator it =  resultList.iterator();
		Iterator it1 = null;
		int i=0;
		while(it.hasNext()){
			flightInfo = (FlightInfo)it.next();
			System.out.println("------------------------第"+(++i)+"个航班------------------------");	
			System.out.println("航班号："+flightInfo.getFlightNo());
			System.out.println("起飞时间："+flightInfo.getTakeOffTime());
			System.out.println("到达时间："+flightInfo.getArriveTime());
			System.out.println("机型："+flightInfo.getPlaneType());
			if (flightInfo.getPrices()!=null) {
				System.out.println("最低价格："+flightInfo.getMinprice());	
				System.out.println("最高价格："+flightInfo.getMaxprice());	
			}
		if (flightInfo.isStopOver()) {
			System.out.println("是否经停：是");
		}else {
			System.out.println("是否经停：否");
		}
		if (!flightInfo.isHaveSeat()) {
			System.out.println("是否有座位：否");
		}
			if(flightInfo.isShareCodeFlag()){
			   System.out.println("是否代码共享: 是");
			   System.out.println("代码共享信息："+flightInfo.getShareCode());
			}else{
				  System.out.println("是否代码共享: 否");
			}
			
			if(flightInfo.getPrices()!=null&&flightInfo.getPrices().size()>0){
				System.out.println("舱位、价格及需知：");
			it1 = flightInfo.getPrices().iterator();
			while(it1.hasNext()){
				priceInfo = (PriceInfo)it1.next();
				System.out.println("   "+priceInfo.getSpace()+"         "+priceInfo.getPrice()+"      "+priceInfo.getRemind());
			}}
			
		}
	   System.out.println("\n");
	   System.out.println("------------------------------------------------------------------");
	  System.out.println("所有航班中的最低价格为:"+resultInfo.getMinPriceFlight());
 
	  System.out.println("所有航班中的最高价格为:"+resultInfo.getMaxPriceFlight());
	 
	  System.out.println("------------------------------------------------------------------");
	  
	}
	
}
